	<?php
define('IN_QY',true);
session_start();
require("include/common.inc.php");
require('sku_model.php');	

		if($_POST['uid']!=""){	

          $uid = $_POST['uid'];	
		
	}else{		
		$uid = $_COOKIE['userid'];		
	}
	
	$fid=trim($_POST['goodid']);
	
    $sqlg = "select * from tbl_taospp where id = ".$fid;
    $queryg=mysql_query($sqlg);
    $rowg=mysql_fetch_array($queryg);

//是否已加入
    $sqlcf = "select * from tbl_taocart where isorder=0 AND  buyunit='".$_POST['skuid']."'  AND  goodsid='".$rowg['id']."' AND userid = '".$uid."'";
    $querycf=mysql_query($sqlcf);
    $rowcf=mysql_fetch_array($querycf);
	if($rowcf){	
$sqlcf1 = "update tbl_taocart set goodsnum=goodsnum+'".$_POST['nums']."'  where isorder=0 AND  buyunit='".$_POST['skuid']."' AND goodsid='".$rowg['id']."' AND userid = '".$uid."'";

mysql_query($sqlcf1);
	$arr = array('error'=>0,'msg'=>'成功1','k'=>$_POST['nums']);
	echo json_encode($arr);	
exit;	
	}
	
	if($_POST['skuid']!=0){
	    $sqlgg = "select * from tbl_goods_sku where id = ".$_POST['skuid'];
    $querygg=mysql_query($sqlgg);
    $rowgg=mysql_fetch_array($querygg);	
		
	$rowg['zswprice']=$rowgg['price'];
	}
	
	
	
	
	
//	
	
$sql="insert into tbl_taocart values(
        0,
        '".$uid."',
        '".$rowg['id']."',
        '".$_POST['nums']."',
        '".$rowg['zswprice']."',
        '".$_POST['vip_price']."',		
        '".$_POST['skuid']."',
        '".$rowg['ggnum']."',
        0,
        '".time()."',
        0,		
        '".$rowg['ggid']."',
        0,
        0,
		0,
        0		
		)";
     
    $query=mysql_query($sql);

	$arr = array('error'=>0,'msg'=>'成功3',);
	echo json_encode($arr);	
	exit;
	?>